<template>
	<view>
		<!-- <uni-sign-in ref="signIn"></uni-sign-in> -->
		<view style="width: 100%;height: 350rpx;background-image: url('static/9.png') ;background-size: 100% 100%;: ;">
			<view style="display: flex; flex-direction: column;">
				<view style="display: flex;justify-content: center;" @click="update_touxiang">
					<image
						style="display: flex;height: 150rpx;width: 150rpx;border-radius: 50%;border: white solid 3rpx; margin-top: 50rpx;"
						:src="src" mode="aspectFill"></image>
				</view>
				<view
					style="display: flex;justify-content: center;margin-top: 10rpx;font-size: 40rpx;font-weight: 500;color: white;">
					{{xinyunxin_name_tel.name}}
				</view>
			</view>
		</view>
		<view v-for="item in caidanlists"
			v-if="xinyunxin_userinfo.permission.indexOf(item.quanxian)!=-1 || item.quanxian=='all' || xinyunxin_userinfo.role.indexOf('guanliyuan')!=-1"
			@click="tiaozhan(item.url)"
			style="display: flex;width: 85%;margin:20rpx auto 0 auto;box-shadow: 1px 1px 5px #c2c2c2;background-color: white;border-radius: 20rpx; flex-direction: row; justify-content: space-between;padding: 20rpx 30rpx;">
			<view class="">
				{{item.name}}
			</view>
			<uni-icons type="forward"></uni-icons>
		</view>

		<view @click="tuichu"
			style="display: flex;width: 40%;background-color: blue;color: white;border-radius: 20rpx;align-items: center;justify-content: center;padding: 20rpx;margin: 40rpx auto 20rpx auto;">
			退出登陆
		</view>
	</view>
</template>

<script>
	import {
		store,
		mutations
	} from '@/uni_modules/uni-id-pages/common/store.js'
	export default {
		data() {
			return {
				caidanlists: [{
						name: "我的资料",
						quanxian: "all",
						url: "/uni_modules/uni-id-pages/pages/userinfo/userinfo"
					},
					{
						name: "修改轮播图",
						quanxian: "xiugai_lunbotu",
						url: "/pages/banner/banner"
					},
					{
						name: "修改分享海报",
						quanxian: "xiugai_lunbotu",
						url: "/pages/share_haibao/share_haibao"
					},
					{
						name: "添加商品分类",
						quanxian: "add_shangpinfenlei",
						url: "/pages/shangpinfenlei_add/shangpinfenlei_add"
					},
					{
						name: "添加商品",
						quanxian: "add_shangpin",
						url: "/pages/shangpin_add/shangpin_add"
					},
					{
						name: "设置",
						quanxian: "all",
						url: ""
					},
					{
						name: "技术支持",
						quanxian: "all",
						url: ""
					},
					{
						name: "重置密码",
						quanxian: "all",
						url: "/uni_modules/uni-id-pages/pages/retrieve/retrieve"
					},
				],
				src: '',
				xinyunxin_userinfo: {
					permission: [],
					role: []
				},
				xinyunxin_name_tel: []
			}
		},
		computed: {
			hasLogin() {
				return store.hasLogin
			}
		},
		async onLoad() {
			this.xinyunxin_name_tel = await uni.getStorageSync('xinyunxin_name_tel')
			this.xinyunxin_userinfo = await uniCloud.getCurrentUserInfo()
			console.log(this.xinyunxin_userinfo);
			this.src = this.xinyunxin_name_tel.avatar ? this.xinyunxin_name_tel.avatar :
				'../../static/uni-center/defaultAvatarUrl.png'

		},
		onShow() {

		},
		computed: {},
		methods: {
			//跳转
			tiaozhan(e) {
				uni.navigateTo({
					url: e
				});
			},
			update_touxiang() {
				// 跳转到uni_modules/uni-id-pages/pages/userinfo/userinfo
				uni.navigateTo({
					url: "/uni_modules/uni-id-pages/pages/userinfo/userinfo"
				})
			},
			async tuichu() {
				await mutations.logout()
				// uniIdCo.logout()
				// uni.removeStorageSync('xinyunxin_userinfo')
				// uni.navigateTo({
				// 		url: "/pages/denglu/denglu"
				// })
			},
			toSettings() {
				uni.navigateTo({
					url: "/pages/ucenter/settings/settings"
				})
			},
			ucenterListClick(item) {
				if (!item.to && item.event) {
					this[item.event]();
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #f8f8f8;
	}
</style>